package pl.iachoo.ctl.tabory.dao.hibernate.services;

import java.util.List;

import org.apache.log4j.Logger;

import pl.iachoo.ctl.tabory.dao.hibernate.interfaces.IVagonService;
import pl.iachoo.ctl.tabory.dao.hibernate.vo.CompositionVO;
import pl.iachoo.ctl.tabory.dao.hibernate.vo.VagonVO;

public class VagonServiceImpl extends BaseDaoService<VagonVO> implements
		IVagonService {

	private final static Logger log = Logger.getLogger(VagonServiceImpl.class);

	private static VagonServiceImpl instance;

	private VagonServiceImpl() {

	}

	public static VagonServiceImpl getInstance() {
		if (instance == null) {
			log.info("Creating new instance of service: VagonServiceImpl");
			instance = new VagonServiceImpl();
		}
		log.info("Retriving service: VagonServiceImpl.");
		return instance;
	}

	@Override
	public List<VagonVO> getAllVagons() throws Exception {
		log.debug("Getting all vagons.");
		VagonVO criterion = new VagonVO();
		criterion.setDeleted(false);
		List<VagonVO> loadList = loadList(VagonVO.class, criterion);
		log.debug(loadList);
		return loadList;
	}

	@Override
	public List<VagonVO> getVagons(CompositionVO composition) throws Exception {
		return null;
	}

	@Override
	public VagonVO getVagon(int vagonId) throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public VagonVO addVagon(VagonVO vagon) throws Exception {
		log.debug("Saving new vagon: " + vagon);
		saveOrUpdate(vagon);
		return vagon;
	}

	@Override
	public void deleteVagon(VagonVO vagon) throws Exception {
		// TODO Auto-generated method stub

	}

}
